package chapter02

object Test20_List {
  def main(args: Array[String]): Unit = {
    val list = List(1, 2, 3, 4)
    println(list)
    //增加元素
    val list1 = list :+ 20:+30:+10
    println(list1)
    val list2 = 25 +: 15 +: list
    println(list2)
    //取其中元素
    val i = list(1)
    val head = list.head
    println(i)
    println(head)
    //合并列表
    val list3 = list1 :: list2
    println(list3)
    val list4 = list1 ::: list2
    println(list4)
    //循环
    for(i<-list4){
      println(i)
    }
    for(i<-0 until  list4.length){
      println(list4(i))
    }
    list4.foreach(e=>{println(e)})
  }
}
